package com.example.c201901090104;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

// 和数据库建立连接
public class OpenSQLHelper extends SQLiteOpenHelper {


//name  数据库名字
    public OpenSQLHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    // 建表
    @Override
    public void onCreate(SQLiteDatabase db) {
//        传入sql  create table user(id integer primary key autoincrement,username varchar(20),password varchar(20),age integer)
        db.execSQL("create table user(id integer primary key autoincrement,username varchar(20),password varchar(20),age integer)");
    }


    // 修改表
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
